Skip to content

feat: Split statistics components computation & output#3836

Open
MelReyCG wants to merge 330 commits intodevelopfrom
bugfix/rey/split-statistics-components
Open

feat: Split statistics components computation & output#3836
MelReyCG wants to merge 330 commits intodevelopfrom
bugfix/rey/split-statistics-components

Conversation

@MelReyCG
Copy link
Contributor

@MelReyCG MelReyCG commented Sep 26, 2025

Issue: #3822
On top of PR : #3829

Planned refactor: The goal is to have a way to query statistics for solver (reservoir reference pressure for wells), with a clear separation with output statistics component.

The solution proposed here aims at giving a single data storage for each component needing statistics computation. In practices, the statistics are no longer recomputed for each convergence step, but only once, at start of each iteration (it gives the same result since the operation is read only).

To achieve these goals, the PR propose to separate each roles, instead of having everything in each *PhaseStatistics class:

  • RegionStatistics classes for resulting data storages at different levels:
    • sub-regions mpi-local kernel compute read-backs,
    • (cell element) regions,
    • solver discretisation MeshLevel,
  • StatsAggregator classes to compute & reduce the statistics to rank 0, can be instanciated as solver helpers (as done for wells in the PR),
  • StatsTask Group, the user component to schedule flow statistics computation & output to log & CSV.

Old stats data architecture (stats are sticked to regions, and shared by all components):

Problem : ProblemManager
|-> domain : DomainPartition
    |-> MeshBodies : Group
        |-> cartesianMesh : MeshBody
            |-> meshLevels : Group
                |-> Level0 : MeshLevel
                |   |-> nodeManager : NodeManager
                |   |   |  * RegionStatistics (aggregate, mpi reduced)  <- stats data
                |   |   |-> sets : Group
                |   |       | * all : Wrapper< index array >
                |   |       | * xneg : Wrapper< index array >
                |   |       [...] (other element sets)
                |   |
                |   |-> ElementRegions : ElementRegionManager
                |   |   |  * RegionStatistics (aggregate, mpi reduced)  <- stats data
                |   |   |-> Channel : CellElementRegion
                |   |   |   |-> cb-0_0_0 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   | * RegionStatistics (compute read-back)  <- stats data
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   |-> cb-0_0_1 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   | * RegionStatistics (compute read-back)  <- stats data
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   [...] (other sub-regions)
                |   |   |
                |   |   |-> Barrier : CellElementRegion
                |   |       |-> cb-1_0_0 : CellElementSubRegion
                |   |       |-> cb-1_0_1 : CellElementSubRegion
                |   |       |-> * RegionStatistics (compute read-back)  <- stats data
                |   |       [...] (other sub-regions)
                |   |
                |   [...] (other element managers)
                |
                [...] (other discretizations)

Proposed new way, with a clear storage for each aggregator instance:

Problem : ProblemManager
|-> domain : DomainPartition
    |-> MeshBodies : Group
        |-> cartesianMesh : MeshBody
            |-> meshLevels : Group
                |-> Level0 : MeshLevel
                |   |-> nodeManager : NodeManager
                |   |   |-> sets : Group
                |   |       | * all : Wrapper< index array >
                |   |       | * xneg : Wrapper< index array >
                |   |       [...] (other element sets)
                |   |
                |   |-> ElementRegions : ElementRegionManager
                |   |   |-> Channel : CellElementRegion
                |   |   |   |-> cb-0_0_0 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   |-> cb-0_0_1 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   [...] (other sub-regions)
                |   |   |
                |   |   |-> Barrier : CellElementRegion
                |   |       |-> cb-1_0_0 : CellElementSubRegion
                |   |       |-> cb-1_0_1 : CellElementSubRegion
                |   |       [...] (other sub-regions)
                |   |
                |   [...] (other element managers)
         ____   |   |
         |      |   |-> statistics : Group (storage for all stats)
         |      |       |-> flowStats : Group (storage for this instance stats)
         |      |       |   |-> regionsStatistics : RegionStatistics (aggregate)
         |      |       |       |-> Channel : RegionStatistics (aggregate, mpi reduced)
         |      |       |       |   |-> cb-0_0_0 : RegionStatistics (compute read-back)
 stats   |      |       |       |   |-> cb-0_0_1 : RegionStatistics (compute read-back)
 data -> |      |       |       |   [...] (other sub-regions stats)
         |      |       |       |
         |      |       |       |-> Barrier : RegionStatistics (aggregate, mpi reduced)
         |      |       |           |-> cb-1_0_0 : RegionStatistics (compute read-back)
         |      |       |           |-> cb-1_0_1 : RegionStatistics (compute read-back)
         |      |       |           [...] (other sub-regions stats)
         |      |       |
         |___   |       [...] (other stats storages)
                |
                [...] (other discretizations)

Decoupling the storage of the CellElementRegion will help to provide a way of obtaining statistics from arbitrary mesh regions (defined by sets for instance).


PR also propose to consolidate testFlowStatistics by also checking the total mass balance of the compositional cases.

amandinehry and others added 30 commits July 21, 2025 11:00
@MelReyCG MelReyCG added ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI labels Mar 4, 2026
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a PreparedTableLayout vs presumably an "non" PreparedTableLayout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TableLayout is the descriptor of the desired layout, and the PreparedTableLayout has precomputed data for optimizing further ascii formatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that answer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in the getTotalFluidMass function and not inside the region stats... could we get rid of the specializations at the getter level...

@MelReyCG
Copy link
Contributor Author

Verified that rebaselining is safe: purely structural, no numerical difference.

@MelReyCG MelReyCG added flag: no rebaseline Does not require rebaseline flag: requires rebaseline Requires rebaseline branch in integratedTests and removed flag: no rebaseline Does not require rebaseline labels Mar 11, 2026
@MelReyCG MelReyCG requested a review from tjb-ltk March 12, 2026 13:56
@MelReyCG MelReyCG removed ci: run integrated tests Allows to run the integrated tests in GEOS CI ci: run CUDA builds Allows to triggers (costly) CUDA jobs labels Mar 13, 2026
@MelReyCG
Copy link
Contributor Author

I'm removing all the CUDA & integrated tests runs until people review this PR, but they ran succesfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: requires rebaseline Requires rebaseline branch in integratedTests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants